export const initState={
    info:sessionStorage.getItem("info")?JSON.parse(sessionStorage.getItem("info")):{}
}

export const reducer = (state,action)=>{
    switch(action.type){
        case "changeInfo":
            return {
                ...state,
                info:action.info
            }
            break
            default:
                return state
    }
}

export const actions={
    changeInfo:(info)=>{
        if(info.token){
            sessionStorage.setItem("info",JSON.stringify(info))
        }else{
            sessionStorage.removeItem("info")

    }
    return {type:"changeInfo",info}
}
}